package cn.fantasy.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 获取连接的工具类
 * @author zhangliang
 */
public class JdbcUtil {
    // 数据库连接池
    private static ConnPool connPool = new ConnPool();

    /**
     * 从池中获取一个连接
     * @return
     * @throws SQLException
     */
    public static Connection getConnection() throws SQLException {
        return connPool.getConnection();
    }

    public static void CloseConnection(Connection conn, Statement st, ResultSet rs) throws SQLException {
        if (conn != null) {
            conn.close();
        }

        if (st != null) {
            st.close();
        }

        if (rs != null) {
            rs.close();
        }
    }
}
